package action;

import pojo.Book;

import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import jms.JmsProducer;
import data.DataLoad;

public class ProduceAction {
	
	public void action(){
		List<Book> books = new DataLoad().load();
		JmsProducer producer = new JmsProducer();
		ObjectMapper mapper = new ObjectMapper();
		for (Book book:books) {
			try {
				producer.produce(mapper.writeValueAsString(book));
			} catch (JsonProcessingException e) {
				e.printStackTrace();
			}
		}
		producer.close();
	}
	public static void main(String[] args) {
		new ProduceAction().action();
	}
}
